package com.one.square.file.interfaces.service.fallback;

import com.one.square.core.domain.Result;
import com.one.square.core.entity.FileInfo;
import com.one.square.file.interfaces.service.service.FileInterFace;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author cwm
 * @Description
 * @date 2021/10/27 下午3:38
 * @Version 1.0
 */
@Slf4j
public class FileInterFaceFallBack implements FallbackFactory<FileInterFace> {
    @Override
    public FileInterFace create(Throwable cause) {
        return new FileInterFace() {
            @Override
            public Result<FileInfo> upload(MultipartFile file) throws Exception {
                log.error("上传文件异常");
                return Result.failed("上传文件异常");
            }

            @Override
            public Result delete(String id) {
                log.error("删除文件异常");
                return Result.failed("上传文件异常");
            }
        };
    }
}
